

class HexString(str):
    """
    represents a string that will be hex-dumped (only via __pretty_str__).
    this class derives of str, and behaves just like a normal string in all
    other contexts.
    """
    def __init__(self, data, linesize = 16):
        str.__init__(self, data)
        self.linesize = linesize
    def __new__(cls, data, *args, **kwargs):
        return str.__new__(cls, data)
    def __pretty__(self, nesting = 1, indentation = "    "):
        if not self:
            return "''"
        sep = "\n" + indentation * nesting
        return sep + sep.join(hexdump(self))



